from typing import List
class Solution:
    def maxScoreSightseeingPair(self, A: List[int]) -> int:
        m, res = 0,0
        for i in range(0, len(A)):
            res = max(res, m+A[i]-i)
            m = max(A[i]+i, m)
        return res


if __name__ == "__main__":
    print(Solution().maxScoreSightseeingPair([8, 1, 5, 2, 6]))
